﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
namespace ChuanPlus
{
    public class OrderDetails : XPLiteObject
    {
        int fOrderDetailsID;
        [Key(true)]
        public int OrderDetailsID
        {
            get { return fOrderDetailsID; }
            set { SetPropertyValue<int>("OrderDetailsID", ref fOrderDetailsID, value); }
        }
        [Association("Order-OrderDetails")]     
        Order fOrderID;
        [Size(10)]
        public Order OrderID
        {
            get { return fOrderID; }
            set { SetPropertyValue<Order>("OrderID", ref fOrderID, value); }
        }
        Stock fStockID;
        public Stock StockID
        {
            get { return fStockID; }
            set { SetPropertyValue<Stock>("StockID", ref fStockID, value); }
        }
        double fQuantity;
        public double Quantity
        {
            get { return fQuantity; }
            set { SetPropertyValue<double>("Quantity", ref fQuantity, value); }
        }
        double fUnitPrice;
        public double UnitPrice
        {
            get { return fUnitPrice; }
            set { SetPropertyValue<double>("UnitPrice", ref fUnitPrice, value); }
        }
        double fVAT;
        public double VAT
        {
            get { return fVAT; }
            set { SetPropertyValue<double>("VAT", ref fVAT, value); }
        }
        private double _SubTotal;
        [NonPersistent]
        public double SubTotal
        {
            get { return _SubTotal; }
            set { _SubTotal = value; }
        }
        public OrderDetails(Session session) : base(session) { }
        public OrderDetails() : base(Session.DefaultSession) { }
        /// <summary>
        /// Initializes a new instance of the OrderDetails class.
        /// </summary>
        /// <param name="fOrderDetailsID"></param>
        /// <param name="fOrderID"></param>
        /// <param name="fID"></param>
        /// <param name="fQuantity"></param>
        /// <param name="fUnitPrice"></param>
        /// <param name="fVAT"></param>
        public OrderDetails(Session session, int fOrderDetailsID, Order fOrderID, Stock fStockID, double fQuantity, double fUnitPrice, double fVAT)
            : base(session)
        {
            this.fOrderDetailsID = fOrderDetailsID;
            this.fOrderID = fOrderID;
            this.fStockID = fStockID;
            this.fQuantity = fQuantity;
            this.fUnitPrice = fUnitPrice;
            this.fVAT = fVAT;
        }
        /// <summary>
        /// Initializes a new instance of the OrderDetails class.
        /// </summary>
        /// <param name="fID"></param>
        /// <param name="fQuantity"></param>
        /// <param name="fUnitPrice"></param>
        /// <param name="fVAT"></param>
        public OrderDetails(Stock fStockID, double fQuantity, double fUnitPrice, double fVAT)
        {
            this.fStockID = fStockID;
            this.fQuantity = fQuantity;
            this.fUnitPrice = fUnitPrice;
            this.fVAT = fVAT;

        }
        public override void AfterConstruction() { base.AfterConstruction(); }
    }

}
